﻿@{
    ViewBag.Title = "保险卡列表";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
@model ZBJF.Warranty.Model.InsuranceProductPackage

<ul class="nav nav-tabs">
    <li class="active"><a href="/SellerInsuranceProducts/">保险卡产品列表</a></li>
    <li class="Add-R"><a href="/SellerInsuranceProducts/AddInsuranceProductPackage?insuranceProductPackage=0">新建保险卡产品</a></li>
</ul>
<form id="searchForm" class="breadcrumb form-search">
    <table class="keep-all">
        <tr>
            <th>保险卡产品名称：</th>
            <td>
                @Html.TextBoxFor(c => c.ProductPackageName, new { maxlength = 20, @class = "input-small" })
            </td>
            <th>创建时间：</th>
            <td colspan="1">
                <input id="CreateTimeStart" class="Wdate input-small" type="text" onfocus="var CreateTimeEnd = $dp.$('CreateTimeEnd'); WdatePicker({ onpicked: function () { CreateTimeEnd.focus(); }, maxDate: '#F{$dp.$D(\'CreateTimeEnd\')}' })" />
                <input id="CreateTimeEnd" class="Wdate input-small" type="text" onfocus="WdatePicker({ minDate: '#F{$dp.$D(\'CreateTimeStart\')}' })" />
            </td>
            <th>是否启用：</th>
            <td>
                <select class="selected" id="IsAvailable">
                    <option>请选择</option>
                    <option value="true">是</option>
                    <option value="false">否</option>
                </select>
            </td>
            <td style="padding-top: 10px; padding-left: 20px;">
                <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
            </td>
        </tr>
    </table>
</form>
<div class="table-responsive dataTables_wrapper">
    <table id="insuranceProductPackageList" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20">序号</th>
                <th width="85">保险卡产品名称</th>
                <th width="85">保险卡编码</th>
                <th width="80">激活期限</th>
                <th width="80">创建时间</th>
                <th width="80">状态</th>
                <th width="80">操作</th>
            </tr>
        </thead>
    </table>
</div>
@section scripts{
    <script type="text/javascript">
        var isSearch = false;
        $(function () {
            var objTable = $("#insuranceProductPackageList")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "aaSorting": [[10, "desc"]],
                    "sAjaxSource": "/SellerInsuranceProducts/Index",
                    aoColumns: [
                        {
                            "mData": null,
                            "bSortable": false,
                            "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                    {
                        "mData": null, "fnRender": function (nRow) {
                            var html = "<a class='Edit-R'  href='/SellerInsuranceProducts/AddInsuranceProductPackage?insuranceProductPackage=" + nRow.aData.ID + "' title='edit'>" + nRow.aData.ProductPackageName + "</a>";
                            return html;
                        }
                    },
                    { "mData": "InsuranceProductPackageNO" },
                    {
                        "mData": null, fnRender: function (nRow) {
                            return nRow.aData.ActiveCardInLimitDays + "天";
                        }
                    },
                    { "mData": "CreateTime" },
                    { "mData": "ID" },
                    { "mData": "ID" }
                    ]
                    , "fnRowCallback": function (nRow, aData, iDisplayIndex) {
                        $('td:eq(5)', nRow).html(aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon);
                        var html = "<a class='Edit-R'  href='/SellerInsuranceProducts/AddInsuranceProductPackage?insuranceProductPackage=" + aData.ID + "' title='edit'><i class='icon-edit'></i></a>";
                        html += "<a class='Edit-R' href=\"javascript:UpdateStatus('" + aData.ID + "'," + !aData.IsAvailable + ",'/SellerInsuranceProducts/UpdateInsuranceProductPackageStatus','insuranceProductPackageList')\" title='" + (aData.IsAvailable ? "禁用" : "启用") + "'>" + (aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                        $('td:eq(6)', nRow).html(html);
                    }
                });
        });
        function search() {
            /*给查询对象赋值*/
            queryParamList.ProductPackageName = $("#ProductPackageName").val().trim();
            queryParamList.IsAvailable = $("#IsAvailable").val();
            queryParamList.CreateTimeStart = $("#CreateTimeStart").val();
            queryParamList.CreateTimeEnd = $("#CreateTimeEnd").val();
            $("#insuranceProductPackageList").dataTable().fnDraw();
        }
    </script>
}

